/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package UserInterface;

import gleem.linalg.Vec4f;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;

/**
 * Barra de progresso usada na HUD
 * @author Gustavo Buzogany Eboli
 */
public class ProgressBar {
    private int x, y;
    private int width, height;
    private float maxValue;
    private float value;
    private Vec4f borderColor;
    private Vec4f color;

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public float getMaxValue() {
        return maxValue;
    }

    public void setMaxValue(float maxValue) {
        this.maxValue = maxValue;
    }

    public float getValue() {
        return value;
    }

    public void setValue(float value) {
        this.value = value;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Vec4f getBorderColor() {
        return borderColor;
    }

    public void setBorderColor(Vec4f borderColor) {
        this.borderColor = borderColor;
    }

    public Vec4f getColor() {
        return color;
    }

    public void setColor(Vec4f color) {
        this.color = color;
    }

    public ProgressBar(int x, int y, int width, int height, float maxValue, float value) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.maxValue = maxValue;
        this.value = value;
        this.borderColor = new Vec4f(1.0f, 1.0f, 1.0f, 1.0f);
        this.color = new Vec4f(1.0f, 0.0f, 0.0f, 1.0f);
    }

    public void draw(GLAutoDrawable drawable, int winHeight)
    {
        GL gl = drawable.getGL();
        gl.glColor4f(borderColor.x(), borderColor.y(), borderColor.z(), borderColor.w());
        gl.glBegin(GL.GL_LINE_LOOP);
        gl.glVertex3f(x, winHeight-y+height, 0.0f);
        gl.glVertex3f(x+width, winHeight-y+height, 0.0f);
        gl.glVertex3f(x+width, winHeight-y, 0.0f);
        gl.glVertex3f(x, winHeight-y, 0.0f);
        gl.glEnd();

        gl.glColor4f(color.x(), color.y(), color.z(), color.w());
        gl.glBegin(GL.GL_POLYGON);
        gl.glVertex3f(x+1, winHeight-y+height, 0.0f);
        gl.glVertex3f(x+(value/maxValue*(width-1)), winHeight-y+height, 0.0f);
        gl.glVertex3f(x+(value/maxValue*(width-1)), winHeight-y+1, 0.0f);
        gl.glVertex3f(x+1, winHeight-y+1, 0.0f);
        gl.glEnd();
    }


}
